/*
 * 软件版权: 恒生电子股份有限公司
 * 修改记录:
 * 修改日期     修改人员  修改说明
 * ========    =======  ============================================
 * 2021/4/9  lisy31662  新增
 * ========    =======  ============================================
 */
package com.sansi.pencilbook.controller;

import com.sansi.pencilbook.DO.ResponseDO;
import com.sansi.pencilbook.DO.Result;
import com.sansi.pencilbook.entity.User;
import com.sansi.pencilbook.service.AmtAccountServer;
import com.sansi.pencilbook.service.UserServer;
import com.sansi.pencilbook.util.ResponseDOUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 功能说明: 资金账户控制器
 *
 * @author lisy31662
 */
@Slf4j
@RestController
@RequestMapping("/api/amtAccount")
public class AmtAccountController extends VerifyController implements BaseController {

  @Autowired
  private AmtAccountServer amtAccountServer;

  @Autowired
  private UserServer userServer;

  @PostMapping("/u/addAmtAccount")
  public ResponseDO addAmtAccount(HttpServletRequest request) {
    String userAccount = "";
    if ("".equals(userAccount=getUserAccount(request))) {
      User user = (User) userServer.getUserByAccount(userAccount).getData();
      Result result = amtAccountServer.addAmtAccount(user.getUserId());
      return ResponseDOUtil.setResponseDO(result.isSuccess(), result.getMsg());
    }else {
      return ResponseDOUtil.setResponseDO(false, "请登录后在操作");
    }
  }

}
